package com.invest.infra.excel.upload.vo;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.collections.CollectionUtils;

import java.util.List;
import java.util.Map;

/**
 * Created by evan on 2016/7/12.
 */
public class RowErrorResult {
    // 第几行
    private int row = 1 ;

    // 业务唯一描述
    private Map<String,String> keyData = Maps.newHashMap();

    // 列错误信息[手机号不能为空 姓名不能为空.....]
    private List<String> errorMessages = Lists.newArrayList();

    public RowErrorResult(int row){
        this.row = row;
    }
    public RowErrorResult(){}

    public int getRow() {
        return row;
    }

    public void setRow(int row) {
        this.row = row;
    }

    public String getErrorLine(){
        StringBuilder builder = new StringBuilder();
        for(String item: errorMessages) {
            builder.append(item).append(" ");
        }
        return builder.toString();
    }

    public List<String> getErrorMessages() {
        return errorMessages;
    }

    public void setErrorMessages(List<String> errorMessages) {
        this.errorMessages = errorMessages;
    }

    public Map<String, String> getKeyData() {
        return keyData;
    }

    public void setKeyData(Map<String, String> keyData) {
        this.keyData = keyData;
    }

    public boolean hasError(){
        return CollectionUtils.isNotEmpty(errorMessages);
    }
}
